import { useState } from 'react'
import './Index.scss'
import Header from './header/Header'
import Main from './main/Main'
import createTo, { state } from '../../../../stores/contextTodoList'
const Index = () => {
  const [isShow, setShow] = useState(true)
  const [todo, setTodo] = useState(state)
  const updateList = (item) => {
    let obj = { ...todo }
    obj.todolist.push(item)
    setTodo(obj)
  }

  // 排序
  const sort = () => {
    setShow(!isShow)
  }
  return (
    <createTo.Provider value={{ ...todo, updateList }}>
      <div className="index">
        <Header />
        <Main sort={sort} isShow={isShow} />
      </div>
    </createTo.Provider>
  )
}

export default Index

// import { useState } from 'react'
// import './Index.scss'
// import Header from './header/Header'
// import Main from './main/Main'
// const Index = () => {
//   const [isShow, setShow] = useState(true)
//   const [list, setList] = useState({
//     list: [
//       { name: '哇哈哈', date: '2017', priority: 1 },
//       { name: '没哈哈', date: '2117', priority: 2 },
//       { name: '有哈哈', date: '2317', priority: 1 },
//       { name: '无哈哈', date: '2567', priority: 3 },
//       { name: '呜哈哈', date: '2021', priority: 2 },
//       { name: '右哈哈', date: '2023', priority: 1 },
//     ],
//   })

//   const add = (item) => {
//     let navList = list.list
//     navList.push(item)
//     setList(() => {
//       return {
//         ...list,
//         list: navList,
//       }
//     })
//   }
//   // 排序
//   const sort = () => {
//     setShow(!isShow)
//   }
//   return (
//     <div className="index">
//       <Header add={add} />
//       <Main list={list} sort={sort} isShow={isShow} />
//     </div>
//   )
// }

// export default Index
